<html>
<head><meta charset="utf-8"><title>odd-panic · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/odd-panic.html">odd-panic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230609926"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/odd-panic/near/230609926" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/odd-panic.html#230609926">(Mar 16 2021 at 23:28)</a>:</h4>
<p>I'm running into a weird situation when using cargo as a library and invoking <code>core::resolver::resolve</code>. Specifically, I get:</p>
<div class="codehilite"><pre><span></span><code>thread &#39;main&#39; panicked at &#39;package cache lock is not currently held, Cargo forgot to call `acquire_package_cache_lock` before we got to this stack frame&#39;
stack backtrace:
   0: std::panicking::begin_panic
   1: cargo::util::config::Config::assert_package_cache_locked
   2: &lt;cargo::sources::git::source::GitSource as cargo::core::source::Source&gt;::update
   3: cargo::core::registry::PackageRegistry::ensure_loaded
   4: &lt;cargo::core::registry::PackageRegistry as cargo::core::registry::Registry&gt;::query
   5: cargo::core::resolver::dep_cache::RegistryQueryer::query
   6: &lt;core::iter::adapters::ResultShunt&lt;I,E&gt; as core::iter::traits::iterator::Iterator&gt;::next
   7: &lt;alloc::vec::Vec&lt;T&gt; as alloc::vec::SpecFromIter&lt;T,I&gt;&gt;::from_iter
   8: cargo::core::resolver::dep_cache::RegistryQueryer::build_deps
   9: cargo::core::resolver::activate
  10: cargo::core::resolver::activate_deps_loop
  11: cargo::core::resolver::resolve
</code></pre></div>
<p>It only seems to happen _some_ of the time. Am I expected to call <code>acquire_package_cache_lock</code> myself before invoking <code>resolve</code> in some situations but not others?</p>



<a name="230611170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/odd-panic/near/230611170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/odd-panic.html#230611170">(Mar 16 2021 at 23:43)</a>:</h4>
<p>Yes, callers need to acquire the lock.</p>



<a name="230611277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/odd-panic/near/230611277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jon Gjengset <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/odd-panic.html#230611277">(Mar 16 2021 at 23:44)</a>:</h4>
<p>Huh, I wonder how I've gotten away with the code _not_ doing that for so long. Should this be documented on <code>resolve</code>?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>